<template>
  <div>
    角色管理
    <el-button type="primary" @click="add">添加</el-button>

    <el-tag type="success" v-for="(item, index) in user" :key="index">{{
      item.name
    }}</el-tag>

    <br />
    <el-button type="primary" @click="clg">打印</el-button>
    <el-button type="primary" @click="addb">添加b</el-button>
    <el-tag type="success" v-if="rrr.b != undefined">{{ rrr.b }}</el-tag>

    <jisuan :count.sync="fcount"></jisuan>
  </div>
</template>

<script>
import jisuan from '../../../components/jisuan.vue'

export default {
  components: { jisuan },
  data() {
    return {
      fcount: 8,

      user: [
        {
          id: 1,
          name: 'user1'
        },
        {
          id: 2,
          name: 'user2'
        },
        {
          id: 1,
          name: 'user1'
        }
      ],

      rrr: { a: 3 },
      tempArr1: [
        { id: 1, name: 'apple' },
        { id: 2, name: 'pen' },
        { id: 3, name: 'book' },
        { id: 3, name: 'mouse' }
      ]
    }
  },
  methods: {
    aaa() {
      let newArr = []
      this.user.forEach((item) => {
        if (item.id) {
        }
      })
    },

    add() {
      this.user.push({ id: 9, name: '555' })
    },
    clg() {
      console.log(this.rrr)
    },
    addb() {
      // this.rrr.b = 8
      this.$set(this.rrr, 'b', 666)
    },
    d() {
      let b = []
      b = tempArr1.filter((item, index) => {
        return tempArr1.findIndex((item1) => item1.id == item.id) == index
      })
    }
  }
}
</script>

<style lang="less" scoped></style>
